package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    public void work(BookList bookList) {

        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入要归还书籍的名称：");
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                book.setLend(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("该书籍不存在，归还失败");
    }
}
